﻿using System;
using Volo.Abp.Collections;

namespace Xms.Abp.BackgroundJob;

public class XmsBackgroundScheduleTriggerOptions
{
    public bool IsEnabled { get; set; } = true;

    /// <summary>
    /// Default: true.
    /// </summary>
    public bool IsScheduleExecutionEnabled { get; set; } = true;

    public int TriggerPollPeriod { get; set; } = 5000;

    public TypeList<IBackgroundSchedule> ScheduleTypes { get; } = new TypeList<IBackgroundSchedule>();

    internal XmsBackgroundScheduleTriggerOptions AddSchedule<TBackgroudSchedule>()
        where TBackgroudSchedule : IBackgroundSchedule
    {
        ScheduleTypes.Add<TBackgroudSchedule>();
        return this;
    }

    internal XmsBackgroundScheduleTriggerOptions AddSchedule(Type scheduleType)
    {
        ScheduleTypes.Add(scheduleType);
        return this;
    }
}
